<template>
  <view class="activity-container">
    <view class="header">
      <text class="title">活动</text>
    </view>

    <view class="activity-tabs">
      <view class="tab-item" :class="{ active: activeTab === 'recommend' }" @tap="activeTab = 'recommend'">
        <text>推荐</text>
      </view>
      <view class="tab-item" :class="{ active: activeTab === 'nearby' }" @tap="activeTab = 'nearby'">
        <text>附近</text>
      </view>
      <view class="tab-item" :class="{ active: activeTab === 'joined' }" @tap="activeTab = 'joined'">
        <text>已报名</text>
      </view>
    </view>

    <view class="activity-list">
      <view class="activity-card" v-for="(activity, index) in activities" :key="index">
        <image :src="activity.cover" class="activity-cover" mode="aspectFill"></image>
        <view class="activity-info">
          <text class="activity-title">{{ activity.title }}</text>
          <view class="activity-meta">
            <view class="meta-item">
              <text class="meta-icon">📅</text>
              <text class="meta-text">{{ activity.date }}</text>
            </view>
            <view class="meta-item">
              <text class="meta-icon">📍</text>
              <text class="meta-text">{{ activity.location }}</text>
            </view>
          </view>
          <view class="activity-stats">
            <text class="stats-text">
              {{ activity.participants }}人已报名
              <text v-if="activity.price > 0" class="price">¥{{ activity.price }}</text>
            </text>
            <button class="join-btn" :disabled="activity.joined">
              {{ activity.joined ? '已报名' : '立即报名' }}
            </button>
          </view>
        </view>
      </view>
    </view>

    <view class="create-activity">
      <button class="create-btn">+ 发布活动</button>
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';

const activeTab = ref('recommend');

const activities = ref([
  {
    id: 1,
    title: '周末户外徒步活动',
    cover: '/static/logo.png',
    date: '10月15日 10:00',
    location: '北京香山公园',
    participants: 28,
    price: 0,
    joined: false
  },
  {
    id: 2,
    title: '摄影爱好者交流会',
    cover: '/static/logo.png',
    date: '10月20日 14:00',
    location: '上海静安区咖啡馆',
    participants: 15,
    price: 30,
    joined: true
  },
  {
    id: 3,
    title: '读书会：《百年孤独》赏析',
    cover: '/static/logo.png',
    date: '10月22日 19:00',
    location: '广州天河区图书馆',
    participants: 32,
    price: 0,
    joined: false
  },
  {
    id: 4,
    title: '美食达人分享会',
    cover: '/static/logo.png',
    date: '10月25日 16:00',
    location: '深圳南山区美食城',
    participants: 22,
    price: 50,
    joined: false
  }
]);

onLoad(() => {
  console.log('活动页面加载');
});
</script>

<style scoped>
.activity-container {
  padding: 30rpx;
  min-height: 100vh;
  background-color: #f7f7f7;
  padding-bottom: 150rpx;
}

.header {
  text-align: center;
  margin-bottom: 60rpx;
}

.title {
  font-size: 44rpx;
  font-weight: bold;
  color: #333;
}

.activity-tabs {
  display: flex;
  background-color: white;
  border-radius: 10rpx;
  margin-bottom: 30rpx;
  box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
}

.tab-item {
  flex: 1;
  text-align: center;
  padding: 30rpx 0;
  font-size: 30rpx;
  color: #666;
}

.tab-item.active {
  color: #6d4aff;
  font-weight: bold;
  border-bottom: 4rpx solid #6d4aff;
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 30rpx;
}

.activity-card {
  background-color: white;
  border-radius: 20rpx;
  overflow: hidden;
  box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
}

.activity-cover {
  width: 100%;
  height: 300rpx;
}

.activity-info {
  padding: 30rpx;
}

.activity-title {
  font-size: 34rpx;
  font-weight: bold;
  color: #333;
  margin-bottom: 20rpx;
  display: block;
  line-height: 44rpx;
}

.activity-meta {
  display: flex;
  gap: 40rpx;
  margin-bottom: 20rpx;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 10rpx;
}

.meta-icon {
  font-size: 28rpx;
}

.meta-text {
  font-size: 26rpx;
  color: #666;
}

.activity-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 20rpx;
  border-top: 1rpx solid #f0f0f0;
}

.stats-text {
  font-size: 26rpx;
  color: #666;
}

.price {
  color: #ff6b6b;
  font-weight: bold;
  margin-left: 20rpx;
}

.join-btn {
  width: 160rpx;
  height: 70rpx;
  line-height: 70rpx;
  font-size: 26rpx;
  background-color: #6d4aff;
  color: white;
  border-radius: 50rpx;
}

.join-btn:disabled {
  background-color: #ccc;
  color: #fff;
}

.create-activity {
  position: fixed;
  bottom: 120rpx;
  right: 40rpx;
}

.create-btn {
  width: 120rpx;
  height: 120rpx;
  border-radius: 50%;
  background-color: #6d4aff;
  color: white;
  font-size: 36rpx;
  box-shadow: 0 4rpx 20rpx rgba(109, 74, 255, 0.3);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>